---
title: Toggle Group
description: A set of two-state buttons that can be toggled on or off.
component: true
links:
  doc: https://www.radix-ui.com/docs/primitives/components/toggle-group
  api: https://www.radix-ui.com/docs/primitives/components/toggle-group#api-reference
---

<ComponentPreview
  name="toggle-group-demo"
  description="A toggle group with three items."
  styleSwitch={true}
  button="copy"
  dots={false}
/>

## Installation

<Tabs defaultValue="cli">

<TabsList>
  <TabsTrigger value="cli">CLI</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">

```bash
npx nyxb@latest add toggle-group
```

</TabsContent>

<TabsContent value="manual">

<Steps>

<Step>Install the following dependencies:</Step>

```bash
 @radix-ui/react-toggle-group
```

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="toggle-group" />

<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsContent>

</Tabs>

## Usage

```tsx
import { ToggleGroup, ToggleGroupItem } from "~/components/ui/toggle-group"
```

```tsx
<ToggleGroup type="single">
  <ToggleGroupItem value="a">A</ToggleGroupItem>
  <ToggleGroupItem value="b">B</ToggleGroupItem>
  <ToggleGroupItem value="c">C</ToggleGroupItem>
</ToggleGroup>
```

## Examples

### Default

<ComponentPreview
  name="toggle-group-demo"
  description="A toggle group with three items."
  styleSwitch={true}
  button="copy"
  dots={false}
/>

### Outline

<ComponentPreview
  name="toggle-group-outline"
  description="A toggle group using the outline variant."
  styleSwitch={true}
  button="copy"
  dots={false}
/>

### Single

<ComponentPreview
  name="toggle-group-single"
  description="A toggle group with single selection."
  styleSwitch={true}
  button="copy"
  dots={false}
/>

### Small

<ComponentPreview
  name="toggle-group-sm"
  description="A toggle group using the small size."
  styleSwitch={true}
  button="copy"
  dots={false}
/>

### Large

<ComponentPreview
  name="toggle-group-lg"
  description="A toggle group using the large size."
  styleSwitch={true}
  button="copy"
  dots={false}
/>

### Disabled

<ComponentPreview
  name="toggle-group-disabled"
  description="A disabled toggle group."
  styleSwitch={true}
  button="copy"
  dots={false}
/>
